<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <!-- <el-form-item label="款号" class="myform-item">
          <el-input
            v-model="form.product_code"
            placeholder="请输入款号"
            clearable
          ></el-input>
        </el-form-item> -->
        <el-form-item label="日期">
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="date"
            type="date"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
          <!-- <el-button type="primary">导出</el-button>
          <el-button type="primary">上传文件</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <el-button style="margin-bottom:10px" type="text">删除选中数据</el-button>
    <el-table
      :data="tableData"
      style="width: 100%"
      border
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <template v-for="(item, index) in tableHeader">
        <el-table-column
          :label="item.name"
          :key="index"
          align="center"
          :prop="item.key"
        >
        </el-table-column>
      </template>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postApisupplychainindex"
    />
  </div>
</template>

<script>
import { postApisupplychainindex } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      date: "",
      form: {
        product_code: "",
        strtime: "",
        endtime: "",
        page: 1,
        size: 10,
      },
      tableHeader: [
        {
          name: "交货日期",
          key: "f_date",
        },
        {
          name: "款号",
          key: "product_code",
        },
        {
          name: "数量",
          key: "sum",
        },
      ],
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postApisupplychainindex(form);
  },
  methods: {
    handleSelectionChange(val) {
        console.log("val-------->",val)
      this.multipleSelection = val;
    },
    // 编辑
    onEdit(e) {
      console.log("编辑", e);
      this.detail = e;
      this.dialogVisible = true;
            
    },
    // 采购列表
    async postApisupplychainindex(data) {
      this.loading = true;
      this.form = data;
      postApisupplychainindex(data)
        .then((res) => {
          this.loading = false;
          console.log("采购列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      let date = this.date;
      if (date) {
        this.form.strtime = date[0];
        this.form.endtime = date[1];
      }
      this.form.page = 1;
      this.form.size = 10;
      this.postApisupplychainindex(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
